﻿using ModubsRTUTempactureCurve.ViewModels;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ModubsRTUTempactureCurve.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        MainViewModel mainViewModel = new MainViewModel();
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = mainViewModel;
        }
        private bool isFold = true;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
        //使用触发器和命令代替了
        //private void Button_Click_1(object sender, RoutedEventArgs e)
        //{
        //    if (isFold)
        //    {

        //        mask.Visibility = Visibility.Visible;
        //        mask.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(128,0,0,0));
        //        ThicknessAnimation thicknessAnimation = new ThicknessAnimation(new Thickness(0, 0, -250, 0),new Thickness(0,0,0,0),new TimeSpan(0,0,0,0,400));
        //        Storyboard.SetTarget(thicknessAnimation, bor_config);
        //        Storyboard.SetTargetProperty(thicknessAnimation,new PropertyPath("Margin"));
        //        Storyboard storyboard = new Storyboard();
        //        storyboard.Children.Add(thicknessAnimation);
        //        storyboard.Begin();
        //    }
        //    else
        //    {
        //        ThicknessAnimation thicknessAnimation = new ThicknessAnimation( new Thickness(0, 0, 0, 0), new Thickness(0, 0, -250, 0), new TimeSpan(0, 0, 0, 0, 400));
        //        Storyboard.SetTarget(thicknessAnimation, bor_config);
        //        Storyboard.SetTargetProperty(thicknessAnimation, new PropertyPath("Margin"));
        //        Storyboard storyboard = new Storyboard();
        //        storyboard.Children.Add(thicknessAnimation);
        //        storyboard.Begin();
        //        storyboard.Completed += (se, ev) =>
        //        {
        //            mask.Visibility = Visibility.Collapsed;
        //        };
        //        storyboard.Begin();

        //    }
        //    isFold = !isFold;
        //}

        protected override void OnClosed(EventArgs e)
        {
            mainViewModel.Dispose();
        }
        private void sb_Completed(object sender, EventArgs e)
        {
            if (this.DataContext is MainViewModel mvm) {
                mvm.IsFold = !mvm.IsFold;
            }
        }
    }
}